package com.wayhome.srpingbootmybatis.async;

import java.io.UnsupportedEncodingException;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;

public class ChannelMessage {

    public static final String OBJ_MESSAGE = "OBJ_MESSAGE";

    public static final String DATA_SPLIT = "@@";

    /**
     * 原始的消息
     */
    private String data;
    /**
     * 通道名称（MQ队列名称）
     */
    private String channelName;

    private long msgId;

    private long handleId;

    private transient Map<String,Object> properties = new HashMap<>();


    public ChannelMessage() {
    }

    public ChannelMessage(long msgId) {
        this.msgId = msgId;
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }

    public long getMsgId() {
        return msgId;
    }

    public void setMsgId(long msgId) {
        this.msgId = msgId;
    }

    public long getHandleId() {
        return handleId;
    }

    public void setHandleId(long handleId) {
        this.handleId = handleId;
    }

    public String getChannelName() {
        return channelName;
    }

    public void setChannelName(String channelName) {
        this.channelName = channelName;
    }

    public Map<String, Object> getProperties() {
        return properties;
    }

    public void setProperties(Map<String, Object> properties) {
        this.properties = properties;
    }


    public static String decode(String str) throws UnsupportedEncodingException {
        return new String(Base64.getDecoder().decode(str), "UTF-8");
    }
}
